/**
 * Created by Administrator on 2017/4/15.
 */
"use strict";
swan_pc
    .factory('OrgCompanyInfo',function($resource,DateUtils){
        return $resource('/api/orgCompanys/:infoid', {infoid:'@infoid',parentId:'@parentId'}, {
            'query': { method: 'GET', isArray: true},
            'queryAll': {
                method: 'GET',
                transformResponse: function (data) {
                    data = angular.fromJson(data);
                    return data;
                }
            },
            'update': {
                method: 'PUT',
                transformRequest: function (data) {
                    return angular.toJson(data);
                }
            },
            'save': {
                method: 'POST',
                transformRequest: function (data) {
                    return angular.toJson(data);
                }
            },
            'delete':{
                method:'DELETE'
            },
            'queryByOrganizationAndNullParent':{ method: 'GET', isArray: true, url:'api/organizations/:infoid/orgCompanysOfNullParent'},
            'queryByOrgnization': { method: 'GET', isArray: true, url:'api/organizations/:infoid/orgCompanys'},
            'queryByOrgnizationPaging': { method: 'GET', isArray: true, url:'api/organizations/:infoid/orgCompanysPaging'},
            'queryAllTopCompanyByOrgnization': { method: 'GET', isArray: true, url:'api/organizations/:infoid/topOrgCompanys'},
            'updateWithParent':{method: 'PUT',url:'api/orgCompanys/:infoid/parentCompany/:parentId'},
            "queryByEO":{
                method:"GET",
                isArray:true,
                url:"api/orgCompanys/findByEO/:id"
            },
            "queryAllICanRead":{
                method:"GET",
                isArray:true,
                url:"api/orgCompanys/findByEOAndOpp"
            }
        });
    })
    .factory('EntityOwner', function ($resource, DateUtils) {
        return $resource('/api/e-owners/:entityId', {
            'query': { method: 'GET', isArray: true},
            'queryAll': {
                method: 'GET',
                transformResponse: function (data) {
                    data = angular.fromJson(data);
                    //data.companyBaseInfo.foundDate = DateUtils.convertLocaleDateFromServer(data.companyBaseInfo.foundDate);
                    return data;
                }
            },
            'update': {
                method: 'PUT',
                transformRequest: function (data) {
                    //data.companyBaseInfo.foundDate = DateUtils.convertLocaleDateToServer(data.companyBaseInfo.foundDate);
                    return angular.toJson(data);
                }
            },
            'save': {
                method: 'POST',
                transformRequest: function (data) {
                    //data.companyBaseInfo.foundDate= DateUtils.convertLocaleDateToServer(data.companyBaseInfo.foundDate);
                    return angular.toJson(data);
                }
            },
            'delete':{
                method:'DELETE'
            },
            'setEntityOwnerById': {
                method: 'POST',
                transformRequest: function (data) {
                    //data.companyBaseInfo.foundDate= DateUtils.convertLocaleDateToServer(data.companyBaseInfo.foundDate);
                    return angular.toJson(data);
                },
                url:'/api/entityOwner_new/:entityId/:memberId'
            },
            'queryEntityOwnerById': { method: 'GET', isArray: true, url:'/api/businessEntity/:entityId/entityOwners'},
        });
    });